package hp.com.service.impl;
import hp.com.dao.AddressDao;
import hp.com.dao.BaseDao;
import hp.com.dao.impl.AddressDaoImpl;
import hp.com.entity.Address;
import hp.com.service.AddressService;

import java.util.List;

public class AddressServiceImpl extends BaseDao implements AddressService {
    AddressDao dao = new AddressDaoImpl();
    @Override
    public void AddAddress(int account, String loc, String name, String number) throws Exception{
        Address addr = new Address();
        addr.setAccountId(account);
        addr.setLocDetail(loc);
        addr.setContactName(name);
        addr.setContactNumber(number);
        AddressDao ad = new AddressDaoImpl();
        ad.addAddressToAccount(addr);
    }

    @Override
    public List<Address> getAddressById(int id) throws Exception {
        return dao.getAddressesById(id);
    }


    @Override
    public String getAddressTextById(int id) throws Exception {
        Address addr= dao.getAddressByDataId(id);
        return ("收件地址："+addr.getLocDetail()+"   收件人："+addr.getContactName()+"   联系电话:"+addr.getContactNumber());
    }
}
